/*
 * @Descripttion: 出手鸭小程序
 * @version:1.0.1 
 * @Author: HHL
 * @Date: 2022-11-15 10:24:46
 * @LastEditTime: 2023-11-08 09:55:31
 * @LastEditors: sueRimn
 */
import Vue from 'vue'
import App from './App'

import store from './store'

import callKf from './utils/kf'
import copy from './utils/copy'
import { hidePhoneNumber, urlJump } from './utils'

import { goPage } from './utils/jump'
import login from './utils/login'
import uniRouter from './utils/uniRouter'

import './style/index.scss'
import './style/theme.css'

Vue.config.productionTip = false

Vue.prototype.callKf = callKf
Vue.prototype.copyText = copy
Vue.prototype.hidePhoneNumber = hidePhoneNumber
Vue.prototype.goPage = goPage
Vue.prototype.urlJump = urlJump
Vue.prototype.goLogin = login
Vue.prototype.uniRouter = uniRouter

// 拦截 navigateBack，显示自定义挽留弹窗
uni.addInterceptor('navigateBack', {
  invoke(args) {
    const pages = getCurrentPages()
    if (pages.length === 0) return true
    
    const currentPage = pages[pages.length - 1]
    
    // 如果是 assess 页面
    if (currentPage.route === 'pages/assess/index') {
      const vm = currentPage.$vm
      
      // 如果不是提交订单后离开，显示挽留弹窗
      if (vm && !vm.isLeavingBySubmit) {
        vm.handleLayerShow('retainRef')
        return false // 阻止返回
      }
    }
    
    return true
  }
})

App.mpType = 'app'

const app = new Vue({
  ...App,
  store,
})
app.$mount()
